Skip to content

Conversation

@AntonNM
Copy link
Contributor

@AntonNM AntonNM commented Feb 2, 2025

Fixed nested ':=' reference assignment fails (#6768)

By reference assignments (':=') with functions that modified the data.table by reference e.g. (foo=function(DT){modify(DT);return(1L)}, DT[,a:=foo(DT)]) returned a mallformed data.table due to the modification of the targeted named column index ("a") during the j expression evaluation

*Completed TODO: by mattdowle from commits to '2-space indentation #2420' to move allocation logic after jsub evaluation

chmatch and setalloccol calls moved below jsub evaluation which fixed name to column index mapping. Warnings and conditions to terminate early remain before the evaluation. selfrefok warning and following branch were split to accommodate this and to avoid duplicate warnings

*Added tests for jsub expressions that modify DT by-reference

Includes the test that initially demonstrated the bug and an additional test case for future regression testing.

*Added test case for integer vector indexing

Removed pre-jsub-eval numerical lhs to name mapping to prevent issues with duplicate name issues.

Closes #6768

*Followed TODO: by mattdowle from resolution to '2-space indentation Rdatatable#2420'

*Added tests for jsub that modify DT by-reference

*Added test case for interger vector indexing
@AntonNM AntonNM changed the title Fixed nested ':=' reference assignment fails (https://github.com/Rdatatable/data.table/issues/6768) Fixed nested ':=' reference assignment fails [#6768](https://github.com/Rdatatable/data.table/issues/6768) Feb 2, 2025
@AntonNM AntonNM changed the title Fixed nested ':=' reference assignment fails [#6768](https://github.com/Rdatatable/data.table/issues/6768) Fixed nested ':=' reference assignment fails (#6768) Feb 2, 2025
@AntonNM AntonNM changed the title Fixed nested ':=' reference assignment fails (#6768) Fixed nested ':=' reference assignment fails Feb 2, 2025
@codecov
Copy link

codecov bot commented Feb 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.06%. Comparing base (4e9c989) to head (4685224).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6789   +/-   ##
=======================================
  Coverage   99.06%   99.06%           
=======================================
  Files          86       86           
  Lines       16604    16613    +9     
=======================================
+ Hits        16449    16458    +9     
  Misses        155      155           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MichaelChirico MichaelChirico added this to the 1.18.0 milestone Feb 3, 2025
@MichaelChirico
Copy link
Member

Hi @AntonNM would you mind merging to current master?

I would usually attempt to do so myself, but your PR is from your fork's master branch which makes this a fair amount more difficult to manage.

@aitap aitap merged commit 8d26f4e into Rdatatable:master Dec 13, 2025
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nested ':=' reference assignment fails

4 participants